﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using FRS_LIB;

namespace FRS_Console_Test
{
    class Program
    {
        static void Main(string[] args)
        {
            FRS test = new FRS_LIB.FRS();
            string name = "cecc";
            bool response;

            test.AddDevice("172.16.160.98", "switchbox", DeviceType.Switchbox );
            test.AddDevice("172.16.160.88", "witchbox", DeviceType.NETIO_230B);
            test.AddDevice("172.16.160.246", "cecc", DeviceType.CECC);

            try
            {
                for (int i = 1; i < 7; i++)
                {
                    response = test.GetDeviceStatus(name, i);
                    Thread.Sleep(500);
                    if (response)
                        test.TurnOnOffDevice(false, name, i);
                    else
                        test.TurnOnOffDevice(true, name, i);
                    Thread.Sleep(500);
                }

                Thread.Sleep(3000);

                for (int i = 1; i < 7; i++)
                {
                    response = test.GetDeviceStatus(name, i);
                    Thread.Sleep(500);
                    if (response)
                        test.TurnOnOffDevice(false, name, i);
                    else
                        test.TurnOnOffDevice(true, name, i);

                    Thread.Sleep(500);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("ewewwe"+ex.Message);
            }
            return;

            name = "switchbox";

            for (int i = 6; i < 12; i++)
            {
                response = test.GetDeviceStatus(name, i);
                Thread.Sleep(250);
                if (response)
                    test.TurnOnOffDevice(false, name, i);
                else
                    test.TurnOnOffDevice(true, name, i);

                Thread.Sleep(250);
            }

            Thread.Sleep(3000);

            for (int i = 6; i < 12; i++)
            {
                response = test.GetDeviceStatus(name, i);
                if (response)
                    test.TurnOnOffDevice(false, name, i);
                else
                    test.TurnOnOffDevice(true, name, i);

                Thread.Sleep(250);
            }
            return;

            response = test.GetDeviceStatus(name, 6);
            if (response)
                test.TurnOnOffDevice(false, name, 6);
            else
                test.TurnOnOffDevice(true, name, 6);

            Thread.Sleep(50);

            name = "witchbox";

            response = test.GetDeviceStatus(name, 3);
            if (response)
                test.TurnOnOffDevice(false, name, 3);
            else
                test.TurnOnOffDevice(true, name, 3);

            Thread.Sleep(2000);

            response = test.GetDeviceStatus(name, 3);
            if (response)
                test.TurnOnOffDevice(false, name, 3);
            else
                test.TurnOnOffDevice(true, name, 3);

            name = "cecc";

            response = test.GetDeviceStatus(name, 3);
            if (response)
                test.TurnOnOffDevice(false, name, 3);
            else
                test.TurnOnOffDevice(true, name, 3);

            Thread.Sleep(2000);

            response = test.GetDeviceStatus(name, 3);
            if (response)
                test.TurnOnOffDevice(false, name, 3);
            else
                test.TurnOnOffDevice(true, name, 3);


            try
            {
            test.AddDevice("172.16.160.100", "ex", DeviceType.CECC);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            try
            {
            test.AddDevice("172.16.160.100", "ex1", DeviceType.NETIO_230B);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            try
            {
            test.AddDevice("172.16.160.100", "ex2", DeviceType.Switchbox);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            

            try
            {
                test.GetDeviceStatus("bla", 4);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }

            try
            {
                test.GetDeviceStatus(name, 10);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
}
